package com.easy.common;

import java.io.Serializable;
import java.math.BigDecimal;

public class OrderResult<T> implements Serializable {

    private Integer code;
    private String message;
    private T data;
    private BigDecimal sum;


    public OrderResult(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> OrderResult<T> success(T data) {
        return new OrderResult<>(200, "Success", data);
    }

    public static <T> OrderResult<T> success() {
        return new OrderResult<>(200, "Success", null);
    }

    public static <T> OrderResult<T> fail(Integer code, String message, T data) {
        return new OrderResult<>(code, message, data);
    }

    public static <T> OrderResult<T> fail(Integer code, String message) {
        return new OrderResult<>(code, message, null);
    }


    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public BigDecimal getSum() {
        return sum;
    }

    public void setSum(BigDecimal sum) {
        this.sum = sum;
    }
}
